package panelSites;

import info.clearthought.layout.TableLayout;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Insets;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

public class ContentPanel extends JPanel implements PanelSitesIface {

	/**
	 * The panel for the message
	 */
	private static final long serialVersionUID = 1L;

	// Inhalt
	private JLabel inhaltLabel = new JLabel("Nachrichtentext");
	private JTextArea inhaltTextArea = new JTextArea(10, 20);
	private JScrollPane inhaltscrollpane = new JScrollPane(inhaltTextArea);

	public ContentPanel(String text) {

		inhaltTextArea.setText(text);
		inhaltLabel.setBackground(Color.LIGHT_GRAY);
		inhaltLabel.setOpaque(true);
		inhaltTextArea.setMargin(new Insets(5,5,5,5));
		double size[][] = { { 150, TableLayout.FILL }, // Columns
				{ 10, 200, TableLayout.FILL } };// Rows

		TableLayout layout = new TableLayout(size);
		layout.setVGap(5);
		layout.setHGap(5);
		setLayout(layout);
		
		//Panel in the top-left corner
		JPanel containsPanel = new ContainsPanel(inhaltLabel);
		containsPanel.add(inhaltLabel, BorderLayout.NORTH);
		
		//Panel for the first line
		JPanel fillPanel = new JPanel();
		fillPanel.setBackground(Color.DARK_GRAY);
		add(fillPanel, "0,0, 1,0");
		add(containsPanel, "0,1");
		add(inhaltscrollpane, "1,1");
		
		//Panel for the rest
		fillPanel = new JPanel();
		fillPanel.setBackground(Color.DARK_GRAY);
		add(fillPanel, "0,2 , 1,2");

	}

	public String getText() {
		return inhaltTextArea.getText();
	}

	public void setText(String text) {
		inhaltTextArea.setText(text);
		
	}
}
